package school.util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class DatabaseManager {

	private SqlSessionFactory factory;
	private static DatabaseManager instance = new DatabaseManager();
	private DatabaseManager(){
		InputStream in = null;
		try{
			in = Resources.getResourceAsStream("school/dao/config/mybatis-config.xml");
		}catch(IOException e){
			e.printStackTrace();
		}
		factory = new SqlSessionFactoryBuilder().build(in);
	}
	public static DatabaseManager getInstance(){
		return instance;
	}
	public SqlSessionFactory getSqlSessionFactory(){
		return factory;
	}
}
